package com.example.wallpaperapp.p;

import com.example.wallpaperapp.bean.UserInfo;
import com.example.wallpaperapp.m.SiginModel;
import com.example.wallpaperapp.m.SininM;
import com.example.wallpaperapp.v.SininV;

/**
 * @Package: com.example.wallpaperapp.p
 * @ClassName: SignInPresent
 * @Description: java类作用描述
 * @Author: zrmo
 * @CreateDate: 2020/11/13 21:43
 */

public class SignInPresent implements SinInP {
    SininV sininV;
    SininM sininM = new SiginModel();
    public SignInPresent(SininV sinin) {
        sininV = sinin;
    }
    @Override
    public void requestMsg() {
        int   userName=sininV.getUserName();
        String   password=sininV.getPassword();
        if (userName==0) {
            sininV.onFailed("用户名不能为空");
        } else if (password.equals("")) {
            sininV.onFailed("密码不能为空");
        }else {
              sininM.postData(userName, password, new SininM.callBack() {
                  @Override
                  public void onSuccess(String msg) {
                      sininV.onSuccess(msg);
                  }
                  @Override
                  public void onFailed(String msg) {
                        sininV.onFailed(msg);
                  }
                  @Override
                  public void result(UserInfo userInfo) {
                      sininV.result(userInfo);
                  }
              });
        }
    }
}
